TrackerUtils = {}

function TrackerUtils.GetFlagSliceForOwner(realm)
    if (realm == GameData.Realm.ORDER)
    then
        return "FlagOrder"
    elseif (realm == GameData.Realm.DESTRUCTION)
    then
        return "FlagDestruction"
    else
        return "FlagNeutral"
    end
end

function TrackerUtils.GetKeepSliceForOwner(realm)
    if (realm == GameData.Realm.ORDER)
    then
        return "OrderKeep"
    elseif (realm == GameData.Realm.DESTRUCTION)
    then
        return "DestructionKeep"
    else
        ERROR(L"Keeps cannot be unaligned.")
        return "OrderKeep"
    end
end

function TrackerUtils.GetDifficultyColor( difficulty )
    if( difficulty == GameData.PublicQuestDifficulty.EASY )
    then
        return DefaultColor.GREEN
    elseif( difficulty == GameData.PublicQuestDifficulty.MEDIUM )
    then
        return DefaultColor.YELLOW
    elseif( difficulty == GameData.PublicQuestDifficulty.HARD
            or difficulty == GameData.PublicQuestDifficulty.VERY_HARD )
    then
        return DefaultColor.RED
    end
    
    return DefaultColor.YELLOW
end

function TrackerUtils.GetDifficultyText( difficulty )
    if( difficulty == GameData.PublicQuestDifficulty.EASY )
    then
        return GetStringFromTable( "ObjectiveTracker", StringTables.ObjectiveTracker.TEXT_PUBLICQUEST_EASY )
    elseif( difficulty == GameData.PublicQuestDifficulty.MEDIUM )
    then
        return GetStringFromTable( "ObjectiveTracker", StringTables.ObjectiveTracker.TEXT_PUBLICQUEST_MEDIUM )
    elseif( difficulty == GameData.PublicQuestDifficulty.HARD
            or difficulty == GameData.PublicQuestDifficulty.VERY_HARD )
    then
        return GetStringFromTable( "ObjectiveTracker", StringTables.ObjectiveTracker.TEXT_PUBLICQUEST_HARD )
    end
    
    return GetStringFromTable( "ObjectiveTracker", StringTables.ObjectiveTracker.TEXT_PUBLICQUEST_MEDIUM )
end

function TrackerUtils.GetDifficultyHelpText( difficulty )
    if( difficulty == GameData.PublicQuestDifficulty.EASY )
    then
        return GetStringFromTable( "ObjectiveTracker", StringTables.ObjectiveTracker.DIFFICULTY_HELP_EASY )
    elseif( difficulty == GameData.PublicQuestDifficulty.MEDIUM )
    then
        return GetStringFromTable( "ObjectiveTracker", StringTables.ObjectiveTracker.TEXT_PUBLICQUEST_MEDIUM )
    elseif( difficulty == GameData.PublicQuestDifficulty.HARD
            or difficulty == GameData.PublicQuestDifficulty.VERY_HARD )
    then
        return GetStringFromTable( "ObjectiveTracker", StringTables.ObjectiveTracker.DIFFICULTY_HELP_HARD )
    end

    return GetStringFromTable( "ObjectiveTracker", StringTables.ObjectiveTracker.DIFFICULTY_HELP_MEDIUM )
end

function TrackerUtils.InitializeOptOutButton()
    ButtonSetCheckButtonFlag( SystemData.ActiveWindow.name, true )
end

function TrackerUtils.OnMouseOverOptOut()

    local optedOutForLootRoll = ButtonGetPressedFlag( SystemData.ActiveWindow.name )
    
    local text
    if (optedOutForLootRoll)
    then
        text = GetStringFromTable( "ObjectiveTracker", StringTables.ObjectiveTracker.LABEL_PQLOOT_OPT_IN)
    else
        text = GetStringFromTable( "ObjectiveTracker", StringTables.ObjectiveTracker.LABEL_PQLOOT_OPT_OUT)
    end

    Tooltips.CreateTextOnlyTooltip( SystemData.ActiveWindow.name, text )
    Tooltips.AnchorTooltip( Tooltips.ANCHOR_WINDOW_LEFT )
end
